package com.hefei.blog.core.lucene.article;

import java.util.Date;

import com.hefei.blog.base.lang.EntityStatus;
import com.hefei.blog.base.lang.EnumPrivacy;
import com.hefei.blog.base.paging.Paging;
import com.hefei.blog.core.data.Post;

public class TestArticleIndex {
	
	public static void main(String args[]) {
//		 testAddIndex();
//		updateAddIndex();
		deleteAddIndex();
		testSearchArticle();
	}

	public static void deleteAddIndex(){
		ArticleIndex.deleteIndex(1l);
	}
	public static void updateAddIndex(){
		Post post = new Post();
		post.setId(1l);
		post.setTitle("第一X次");
		post.setSummary("七月二十八日，中央军委颁授“八一勋章”和授予荣誉称号仪式在北京八一大楼隆重举行。中共中央总书记、国家主席、中央军委主席习近平向“八一勋章”获得者颁授勋章和证书，向获得荣誉称号的单位颁授奖旗。这是习近平向获得荣誉称号");
		post.setFilepath("//2017//07//28//28163620y32x.html");
		post.setTags("中国,中邮,中央");
		post.setPrivacy(EnumPrivacy.OPEN.getIndex());
		post.setFeatured(1);
		post.setFavors(1);
		post.setComments(1);
		post.setViews(1);
		post.setStatus(EntityStatus.STATUS_NORMAL);
		post.setCreated(new Date());
		ArticleIndex.updateIndex(post);
	}
	private static void testAddIndex() {
		Post post = new Post();
		post.setId(1l);
		post.setTitle("第一次");
		post.setSummary("七月二十八日，中央军委颁授“八一勋章”和授予荣誉称号仪式在北京八一大楼隆重举行。中共中央总书记、国家主席、中央军委主席习近平向“八一勋章”获得者颁授勋章和证书，向获得荣誉称号的单位颁授奖旗。这是习近平向获得荣誉称号");
		post.setFilepath("//2017//07//28//28163620y32x.html");
		post.setTags("中国,中邮,中央");
		post.setPrivacy(EnumPrivacy.OPEN.getIndex());
		post.setFeatured(1);
		post.setFavors(1);
		post.setComments(1);
		post.setViews(1);
		post.setStatus(EntityStatus.STATUS_NORMAL);
		post.setCreated(new Date());
		ArticleIndex.addIndex(post);

		Post post1 = new Post();
		post1.setId(2l);
		post1.setTitle("第二次中");
		post1.setSummary("省部级主要领导干部“学习习近平总书记重要讲话精神，迎接党的十九大”专题研讨班在京举行");
		post1.setFilepath("//2017//07//28//28163620y32y.html");
		post1.setTags("中国,中邮,中央");
		post1.setPrivacy(EnumPrivacy.OPEN.getIndex());
		post1.setFeatured(1);
		post1.setFavors(1);
		post1.setComments(1);
		post1.setViews(1);
		post1.setStatus(EntityStatus.STATUS_NORMAL);
		post1.setCreated(new Date());
		ArticleIndex.addIndex(post1);
	}

	private static void testSearchArticle(){
		Paging p = new Paging(0, 2);
		ArticleIndex.searchArticle(p, "中国");
		
		for(Object post : p.getResults()){
			Post p1 = (Post) post;
			System.out.println(p1.getId());
			System.out.println(p1.getTitle());
			System.out.println(p1.getSummary());
			System.out.println("=================================");
		}
	}
	
}
